const vscode = require("vscode");




class itemHandle {
  constructor(interfaces) {
    this.ctx = null;
    this.interfaces = interfaces;
  }
  setctx(ctx) {
    this.ctx = ctx;
    this.init();
  }
  init() {
    const that = this;
    const handle = vscode.commands.registerCommand(
      "daodan.itemHandle",
      (params) => {
        // console.log(333, params);
        if (params.contextValue == "dir") {
          params.collapsibleState = 1 - params.collapsibleState;
        }
        that.ctx.globalState.update('daodan.selectItem', params.id);
        that.interfaces.refresh(params.id);
        vscode.commands.executeCommand("daodan.refreshItem", {})
        vscode.commands.executeCommand("daodan.openWeb", {
          id: params.id,
          tid: params.id,
          label: params.label,
          title: "项目详情",
          type: params.contextValue,
        });
      }
    );
    this.ctx.subscriptions.push(handle);
  }
}

module.exports = {
  itemHandle,
};
